package com.xmkj.winmoney.jifen;

import android.content.Context;
import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;

import com.common.Entity.JingPiaJieXiaoEntity;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.winmoney.R;

import java.util.List;

/**
 * Create by leo
 * 创建日期：2018/5/22
 * 描述：
 */

public class JingPaiJieXiaoAdapter extends CommonAdapter<JingPiaJieXiaoEntity.ListsEntity> {
    public JingPaiJieXiaoAdapter(Context context, List<JingPiaJieXiaoEntity.ListsEntity> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, JingPiaJieXiaoEntity.ListsEntity item, int position) {
        holder.setText(R.id.tv_qi_time,"第"+item.fvid+"期( 揭晓时间："+item.opentime+")");
        SpannableString name = new SpannableString(item.nickname);
        name.setSpan(new ForegroundColorSpan(Color.parseColor("#1ac6e1")), 0, name.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        holder.setText(R.id.tv_name,"成交人:"+name);


        SpannableString chenjiaoprice = new SpannableString(item.deal_price);
        chenjiaoprice.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0E41")), 0, chenjiaoprice.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        holder.setText(R.id.tv_chengjiao_price,"成交价:"+chenjiaoprice);

        SpannableString price = new SpannableString(item.goods_price);
        price.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0E41")), 0, price.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        holder.setText(R.id.tv_price,"市场价:"+price);
        holder.setImageAvatar(R.id.iv_pic,item.face);
    }

    @Override
    protected int getItemViewLayoutId(int position, JingPiaJieXiaoEntity.ListsEntity item) {
        return R.layout.item_jingpai_jiexiao;
    }
}
